package com.up.mongo.properties;


import org.springframework.data.domain.Sort;

import java.util.List;

/**
 * 具体的索引配置
 */
public class AutoCreateIndexLocalCatch {

    /**
     * 索引唯一标识
     */
    private String id;
    /**
     * 属于那个模块
     */
    private IndexModule module;
    /**
     * 属于那个模块名称
     */
    private String moduleName;
    /**
     * 单个则为单个索引，多个则为符合索引(最左匹配原则)
     */
    private List<Indexes> indexes;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public IndexModule getModule() {
        return module;
    }

    public void setModule(IndexModule module) {
        this.module = module;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public List<Indexes> getIndexes() {
        return indexes;
    }

    public void setIndexes(List<Indexes> indexes) {
        this.indexes = indexes;
    }

    public static class Indexes{

        private String indexName;
        private String entityName;
        private List<String> indexFields;
        private boolean unique;
        private Sort.Direction direction = Sort.Direction.ASC;

        public String getIndexName() {
            return indexName;
        }

        public void setIndexName(String indexName) {
            this.indexName = indexName;
        }

        public String getEntityName() {
            return entityName;
        }

        public void setEntityName(String entityName) {
            this.entityName = entityName;
        }

        public List<String> getIndexFields() {
            return indexFields;
        }

        public Sort.Direction getDirection() {
            return direction;
        }

        public void setDirection(Sort.Direction direction) {
            this.direction = direction;
        }

        public void setIndexFields(List<String> indexFields) {
            this.indexFields = indexFields;
        }

        public boolean isUnique() {
            return unique;
        }

        public void setUnique(boolean unique) {
            this.unique = unique;
        }
    }

}
